package il.ac.bgu.cs.heuristics.graph.pddl.parser;

import il.ac.bgu.cs.heuristics.graph.pddl.parser.types.FreeParameter;
import il.ac.bgu.cs.heuristics.graph.pddl.parser.types.Type;
import il.ac.bgu.cs.heuristics.utils.CollectionUtils;

import java.util.List;
import java.util.Map;
import java.util.Set;

import junit.framework.Assert;
import junit.framework.TestCase;

public class TestAbstractParameter extends TestCase {
	public void testAddPossiableTypes() {

		Type type = Type.from("locatable");
		Type type1 = Type.from("location");

		Type type2 = new Type("driver", type);
		Type type3 = new Type("trunk", type);
		List<Type> list1 = CollectionUtils.newArrayList();
		list1.add(type2);
		list1.add(type3);

		Type type4 = new Type("europe", type1);
		List<Type> list2 = CollectionUtils.newArrayList();
		list2.add(type4);

		Type type5 = new Type("rome", type4);
		List<Type> list3 = CollectionUtils.newArrayList();
		list3.add(type5);

		Map<Type, List<Type>> map = CollectionUtils.newHashMap();
		map.put(type, list1);
		map.put(type1, list2);
		map.put(type4, list3);

		Set<Type> set = CollectionUtils.newLinkedHashSet();
		set.add(type);
		FreeParameter freeParam = new FreeParameter("?obj", set);
		freeParam.addPossiableTypes(map);
		Assert.assertEquals(3, freeParam.getPossibleTypes().size());

		Set<Type> set1 = CollectionUtils.newLinkedHashSet();
		set1.add(type1);
		FreeParameter freeParam1 = new FreeParameter("?obj", set1);
		freeParam1.addPossiableTypes(map);
		Assert.assertEquals(3, freeParam1.getPossibleTypes().size());

	}
}
